package org.example.controller;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@SpringBootApplication
@Controller
public class SessionController {

    public static void main(String[] args) {
        SpringApplication.run(SessionController.class, args);
    }


    @RequestMapping("/login")
    public String login(@RequestParam String id, @RequestParam String passwd,
                        HttpServletRequest Request, Model model) {
        if ("123".equals(passwd)) {

            Request.setAttribute("id", id);
            model.addAttribute("logId", id);
            return "main";
        }
        return "login";
    }
@GetMapping("login")
    public String login()
{
    return "login";
}

}
